package com.voicechat.firstmet.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.voicechat.firstmet.R;
import com.voicechat.firstmet.bean.VipCustomBean;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * @ProjectName: FirstMet
 * @Package: com.voicechat.firstmet.adapter
 * @ClassName: FristVIPBannerAdapter
 * @Description: 初见不是会员滑动adapter
 * @Author: ljp
 * @CreateDate: 2018/10/17 16:20
 * @Version: 1.0
 */
public class FristVIPBannerAdapter extends RecyclerView.Adapter<FristVIPBannerAdapter.ItemViewHolder> {
    private final Context context;
    private String TAG = "FristVIPBannerAdapter";


    private List<VipCustomBean> lists;

    public FristVIPBannerAdapter(Context context, List<VipCustomBean> urlList) {
        this.context = context;
        this.lists = urlList;
    }

    @NonNull
    @Override
    public ItemViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        ItemViewHolder itemViewHolder = new ItemViewHolder(LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_vip_frist_met, viewGroup, false));
        return itemViewHolder;
    }

    @Override
    public void onBindViewHolder(@NonNull ItemViewHolder itemViewHolder, int position) {
        if (itemViewHolder instanceof ItemViewHolder) {
            VipCustomBean listBean = lists.get(position);
            itemViewHolder.firstVipIcon.setImageResource(listBean.getIcon());
            itemViewHolder.linearBackAge.setBackgroundResource(listBean.getBg());
            itemViewHolder.tvText.setText(listBean.getVipText());
            itemViewHolder.tvTitle.setText(listBean.getVipTitle());
        }
    }
    @Override
    public int getItemCount() {
        return lists.size();
    }

    class ItemViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.first_vip_icon)
        ImageView firstVipIcon;
        @BindView(R.id.tv_text)
        TextView tvText;
        @BindView(R.id.tv_title)
        TextView tvTitle;
        @BindView(R.id.linear_back_age)
        LinearLayout linearBackAge;
        public ItemViewHolder(@NonNull View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}
